programming4us
           
 
 
Windows

SOA with .NET and Windows Azure: WCF Extensions - WCF Transactions (part 1)

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/29/2010 7:59:21 PM
We introduced some of the original .NET technologies used to enable and manage cross-service transactions. A de-facto industry standard that governs transactions across Web services is WS-AtomicTransaction, which is an extension of (and provides a set of transaction protocols for) the WS-Coordination standard. WCF implements the WS-AtomicTransaction standard and provides a range of transaction-related features, all of which are encompassed in the System.Transactions namespace .

Note

The WS-Coordination and WS-AtomicTransaction industry standards are described in more detail in the book Service-Oriented Architecture: Concepts, Technology, and Design. The original specifications can be accessed via www.soaspecs.com.


A WCF transaction is carried out by two mechanisms:

  • transaction manager

  • resource manager

The resource manager keeps track of durable or volatile data during the lifespan of a given transaction. The transaction manager works with the resource manager to provide a guarantee of atomicity and isolation. In WCF, transactions can be applied to a service using the ServiceBehavior or OperationBehavior attributes.

Operation Attributes for Transactions

An operation attribute allows the internal behavior of a transaction to be changed in a manner that is specific to an operation. In the following code sample, the TransactionFlowOption attribute allows the DebitAccount operation to be invoked inside another transaction. The TransactionScopeRequired operation ensures that if the calling process does not include a transaction, a new transaction will be initiated by the DebitAccount operation.

Example 1.
[TransactionFlow(TransactionFlowOption.Allowed)]
[OperationBehavior(TransactionScopeRequired = true,
TransactionAutoComplete = true)]
void DebitAccount(string accountNo, double amount);

Operation attributes used to change the internal behavior of an operation are:

TransactionScopeRequired

Setting the TransactionScopeRequired attribute to “true” specifies that the operation must be a part of a transaction. If one is not available, a new transaction will be created.

TransactionAutoComplete

Setting the TransactionAutoComplete attribute to “true” indicates that the code need not be implicitly told to abort or commit a transaction. If all the operations in a transaction complete successfully, the transaction will automatically commit itself. Setting the property to false requires you to write code to either commit or roll back the transaction.

TransactionFlow

The TransactionFlow attribute is used to verify at design-time if an operation will accept incoming transaction calls. Possible values for this parameter are as shown in Table 1.

Table 1. Parameter values of the TransactionFlow attribute.
Parameter ValueDescription
Allowedtransactions may flow through to the operation
Mandatorythe transaction context created earlier must flow through
NotAllowedtransactions created earlier will not flow through to the new operation

Service Attributes for Transactions

Service attributes allow the internal behavior of a transaction to be changed to better meet your requirements. In Example 2, if the session in whose context the transaction executes expires, the transaction will be allowed to complete. The isolation level is set to ReadCommitted, implying that transactions can read volatile data but cannot modify it.

Example 2.
[ServiceBehavior(InstanceContextMode =
InstanceContextMode.Single
ConcurrencyMode = ConcurrencyMode.Multiple,
TransactionAutoCompleteOnSessionClose = true,
TransactionIsolationLevel=
System.Transactions.IsolationLevel.ReadCommitted)]
class AccountService : IAccount
{
...
}

Service attributes that can be used to change the internal behavior of transactions include:

TransactionIsolationLevel

In order to maintain data integrity, a transaction must obtain locks on the data involved with the transaction. Obtaining locks comes at the expense of concurrency, thereby preventing other transactions from accessing the same data, and perhaps associated resources.

When a transaction is created, the isolation level for the transaction must be specified. This value determines the level of access that other transactions will have to volatile data. Transaction isolation level options available to the TransactionIsolationLevel parameter are listed in Table 2.

Table 2. A list of level options for transaction isolation.
Isolation LevelDescription
ReadCommittedpermits reading committed (permanent) changes to the data by simultaneous transactions (it also does not permit modifying volatile data)
ReadUncommitteduses the optimistic concurrency model (permits reading and modifying of volatile data)
RepeatableReadpermits reading volatile data but does not permit modifying it (but it does permit adding new data)
Serializablepermits reading volatile data, but does not permit either modifying existing data or adding new data (outcome is similar to transactions executed one after the other—serially)
Snapshotuses the optimistic concurrency model and guarantees that all reads made in a transaction will see a consistent snapshot of the database (the transaction will be committed only if the updates made in the transaction do not conflict with any updates made since that snapshot)


Other -----------------
- Windows 7: Recovering from a Problem
- Windows 7: Troubleshooting Tools (part 3) - Checking for Solutions to Problems
- Windows 7: Troubleshooting Tools (part 2) - Running the Memory Diagnostics Tool
- Windows 7: Troubleshooting Tools (part 1) - Running the Windows 7 Troubleshooters
- Windows Vista : User Account Control
- Windows 7 : Troubleshooting Strategies - Determining the Source of a Problem (part 3)
- Windows 7 : Troubleshooting Strategies - Determining the Source of a Problem (part 2)
- Windows 7 : Troubleshooting Strategies - Determining the Source of a Problem (part 1)
- Windows 7 : Enabling MAC Address Filtering
- Windows 7 : Changing the Default SSID
- Windows 7 : Disabling Network SSID Broadcasting
- Windows 7 : Encrypting Wireless Signals with WPA
- Windows 7 : Positioning the Access Point for Maximum Security
- SOA with .NET and Windows Azure : WCF Extensions - WCF Security
- Windows 7 : Specifying a New Administrative Password
- Windows 7 : Displaying the Router’s Setup Pages
- Windows 7 : Preventing Users from Logging On at Certain Times
- Windows 7 : Removing Stored Remote Desktop Credentials
- Windows 7 : Disabling the Hidden Administrative Shares
- Windows 7 : Hiding Your Shared Folders
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us